package excercise.Page28;

/**
 * @Author: Miyako
 * @Date: 2024-07-15-9:20
 * @Description:矩形
 */
public class Rectangle extends Shape{

Rectangle(){
}
Rectangle(double x , double y){
    setX(x);
    setY(y);
}
    @Override
    double area() {
       return super.area=super.getX()*super.getY();
    }

    @Override
    double perimeter() {
        return super.perimeter = super.getX()*2+super.getY()*2;
    }

    @Override
    void print() {
        for (int y = 0; y<getY();y++){//高
            for (int x = 0; x<getX();x++){//宽
            System.out.print(" * ");
            }
            System.out.println();
        }
    }
}
